<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <ul>
        <li>苹果</li>
        <li>香蕉</li>
        <li>西瓜</li>
    </ul>
</div>
</body>
<script>

    var lis=document.getElementsByTagName("li");
    lis[0].onclick=function(){
        alert("苹果")
    }
</script>
</html>